---@class Battle.AiDoSkillAction:Battle.AiLeaf
---@field New fun():Battle.AiDoSkillAction
local AiDoSkillAction = Battle.CreateClass("AiDoSkillAction",Battle.AiLeaf)
Battle.AiDoSkillAction = AiDoSkillAction
local t = AiDoSkillAction
function t:Awake()
    self:SetParamKey(1,"skillId")
end
function t:onInitialize()
    self.skillId = self:GetParam("skillId")
    self.actor = self:GetActor()
    ---@type Battle.Skill
    self.skill = nil
    if self.actor:IsDead() then return end
    self.skill = self.actor.skillSystem:DoSkill(self.skillId)
    if self.skill == nil then return end
    local target = self.skill.emitter:GetReleaseTarget()
    if target and target ~= self.actor then
        self.actor:RotateTowards(target.pos.x-self.actor.pos.x,0,target.pos.z-self.actor.pos.z)
    elseif self.skill:IsNeedHand() then
        local f = self.skill.emitter:GetReleaseForward()
        self.actor:RotateTowards(f.x,f.y,f.z)
    end
end
function t:update(dt)
    if self.actor:IsDead() or self.skill == nil then
        return Battle.AiTreeStatus.FAILURE
    end
    if self.skill:IsSkillEnd() then
        return Battle.AiTreeStatus.SUCCESS
    end
    return Battle.AiTreeStatus.RUNNING
end
function t:onTerminate()
    if self.skill then
        self.skill:End(true)
    end
end
function t:ToString()
    local s = Battle.AiBehavior.ToString(self)
    return s.." skillId "..self.skillId
end